%
%
%
% triangulate mesh
function [] = triangulate( dir, animFile, outputFile )

addPath( genpath('../../dependencies/crust/') );
addPath( genpath('../export') );
animFilePath = strcat( strcat( dir, animFile), '.mat');
frames = load(animFilePath);
frames = frames.markerData;
[nX, nY] = size(frames);
frame = frames(1, :);
exportOBJ('face_original.obj', frame, 0);


n = nY / 3;
v = zeros(n, 3);
for i = 1:n
    for j = 1:3
        v(i, j) = frame(1, (i - 1) * 3 + j);
    end
end % for

[t,tnorm] = MyRobustCrust(v);
exportOBJ('face_new.obj', frame(1,:), t);
save( strcat(outputFile, '.mat'), 't');


end % function triangulate

